package games.mapacman.common;

import games.mapacman.client.GameScreen;
import games.mapacman.client.Sprite;
import games.mapacman.server.MaPacmanZone;
import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import marauroa.common.game.Definition.Type;

public class ZoneChangePoint {

	private RPObject zoneChange;
	private int x,y;
	
	
	public ZoneChangePoint(RPObject object) {
		zoneChange=object;
		x=zoneChange.getInt("x");
		y=zoneChange.getInt("y");
	}

	public ZoneChangePoint(MaPacmanZone zone, String newzone, int xpos, int ypos) {
		this.x = xpos;
		this.y = ypos;
		zoneChange = new RPObject();
		zoneChange.put("type",consts.TYPE_ZONECHANGE);
		zoneChange.put("newzone",newzone);
		zoneChange.put("zoneid",zone.getName());
		zoneChange.put("x",x);
		zoneChange.put("y",y);
	}

	public static void initRPClass()
	{
		RPClass zonechange = new RPClass(consts.TYPE_ZONECHANGE);
		  zonechange.isA("position");
		  zonechange.addAttribute("newzone",Type.STRING);
	}

	public boolean isPlacedAt(int newX, int newY) {
		return (newX==x && newY==y);
	}

	public String getZoneName() {
		return zoneChange.get("newzone");
	}

	public void draw(GameScreen screen, Sprite sprite_zonechange) {
		screen.repaintArea(x,y,0);
		screen.draw(sprite_zonechange,x,y);
		
	}

	public RPObject getRPObject() {
		return zoneChange;
	}


}

